#include "stdio.h"
#include "stdlib.h"
#include "string.h"

int countDistinctWord(char s[]) {
    // todo add your algorithm here
	int len = strlen(s);
	int i, count, flag, count_d, j, count_result;
	char dist[80][20];

	count = 0; count_d = 0;
	flag = 0;
	for (i=0; i<len; i++){
		if(s[i]!=' ' && flag == 0){
			count++; count_d++;
			flag = 1;
			dist[count][0] = s[i];
		}
		else if( s[i] != ' ' && flag == 1){
			dist[count][count_d] = s[i];
			count_d++;
		}
		else if( s[i] == ' '){
			dist[count][count_d] = '\0';
			flag = 0; count_d = 0;
		}
	}
	dist[count][count_d] = '\0';
	count_result = count;
	flag = 0;
	for (i=count; i>=0; i--){
		for (j=i-1; j>=0; j--){
			if(strcmp(dist[i], dist[j]) == 0)
				flag = 1;
		}
		if (flag == 1){
			count_result--;
			flag = 0;
		}
	}
	return count_result;
}

int main(void) {
	char s[] = "a b c def asg da fe d c b";
	printf("%d", countDistinctWord(s));
	getchar();
	return 0;
}